package com.hl.web.fore;

import com.hl.pojo.FieldOfExcellence;
import com.hl.service.FieldOfExcellenceService;
import com.hl.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/fieldOfExcellence")
public class FieldOfExcellenceController {
    @Autowired
    private FieldOfExcellenceService fieldOfExcellenceService;
    @PostMapping("/add")
    public ResultEntity add(@RequestBody FieldOfExcellence fieldOfExcellence){
        return ResultEntity.ok(fieldOfExcellenceService.add(fieldOfExcellence));
    }

    @GetMapping("/findAll")
    public ResultEntity findAll(){
        return ResultEntity.ok(fieldOfExcellenceService.findAll());
    }

    @GetMapping("/findById")
    public ResultEntity findById(Integer id){
        return ResultEntity.ok(fieldOfExcellenceService.findById(id));
    }

    @GetMapping("/findByFieldName")
    public ResultEntity findByFieldName(String fieldName){
        return ResultEntity.ok(fieldOfExcellenceService.findByFieldName(fieldName));
    }

    @PostMapping("/update")
    public ResultEntity update(@RequestBody FieldOfExcellence fieldOfExcellence){
        fieldOfExcellenceService.update(fieldOfExcellence);
        return ResultEntity.ok();
    }

    @GetMapping("/deleteById")
    public ResultEntity deleteById(Integer id){
        fieldOfExcellenceService.deleteById(id);
        return ResultEntity.ok();
    }
}
